from flask import Flask
from flask import render_template,redirect,url_for

app = Flask(__name__)

class Student(object):
    def __init__(self,name,gender):
        self.name = name
        self.gender = gender

@app.route("/show")
def show():
    # 普通内容
    num = 199
    text = "Noly is good boy."
    student = Student("小星","Male")

    # 列表
    data = ["Hello world",100,200,39]
    # 字典
    source = {"bname":"Google Chrome","special":"fast","year":3}

    return render_template("numbers.html",
                           num=num,
                           text=text,
                           student=student,
                           data=data,
                           source=source,
                           **source)

@app.route("/index")
def index():
    return render_template("index.html")

@app.route("/reindex")
def reindex():
    # 下一个网址
    next_url = url_for("index",_external=True)
    print("完整路径:",next_url)
    return redirect(next_url)

if __name__ == '__main__':
    app.run(debug=True)